import com.AAA.Util.SqlSessionFactoryUtil;
import com.AAA.dao.IEmpDao;
import com.AAA.entity.Emp;
import org.apache.ibatis.session.SqlSession;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.util.List;
import java.util.Map;

public class lambda {
    SqlSession sqlSession;
     IEmpDao mapper;

    @After   //Test执行之后 执行的代码
    public void after(){
        sqlSession.commit();
        sqlSession.close();
    }

    @Before  // 在@Test之前执行
    public void before(){
        sqlSession = SqlSessionFactoryUtil.getSqlSession();
        mapper= sqlSession.getMapper(IEmpDao.class);
    }
    @Test
    public void test(){
        List<Emp> maps = mapper.selectAll();
       maps.stream().filter(emp -> emp.getAge() > 8).limit(10).sorted((e1, e2) -> e2.getAge() - e1.getAge()).forEach(System.out::println);
    }
}
